package com.woniu.commentorder.mapper;

import com.hc.entity.Comment;
import com.hc.entity.Paper;
import com.hc.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CommentMapper {
    @Update("update hc_comment set likenum=likenum+1 where id =#{id}")
    public void inform(int id);
    @Select("select * from hc_comment where paper_id=#{id}")
    @Results({
            @Result(column = "paper_id",property = "paper.id"),
            @Result(column = "id",property = "id"),
            @Result(column = "text",property = "text"),
            @Result(column = "fid",property = "fid"),
            @Result(column = "likenum",property = "likenum"),
            @Result(column = "unlikenum",property = "unlikenum"),
            @Result(column = "user_id",property = "user.id")
    })
    public List<Comment> seleByPid(Paper paper);
    @Insert("insert into hc_comment (id,paper_id,text,fid,likenum,unlikenum,user_id) values(#{id},#{paper.id},#{text},#{fid},#{likenum},#{unlikenum},#{user.id})")
    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
    public void addComment(Comment comment);
}
